<template>
  <div id="centerBottom">
    <div class="bottomLeftTitle">
      <div class="asTitle">视联网</div>
    </div>
    <div class="up">
      <div class="secondTitle">数字乡村平台</div>
      <div class="secondItem">
        <div class="item" v-for="(item, index) in titleItem" :key="index">
          <!-- 小块块上的字体设置 -->
          <p class="ml-3 h-24 colorBlue fw-b fs-xxxxl">{{ item.title }}</p>
          <div class="dv-dig-flop ml-1 mt-8 pl-3">
            {{ item.number.number[0] }} {{ item.number.content }}
          </div>
        </div>
      </div>
    </div>
    <div class="down">
      <div class="ranking">
        <div id="temperature-line" class="chart-con"></div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      titleItem: [
        {
          title: "服务乡村数",
          number: {
            number: [120],
            toFixed: 1,
            textAlign: "left",
            content: "个",
            style: {
              fontSize: 36,
            },
          },
        },
        {
          title: "服务人口",
          number: {
            number: [1008],
            toFixed: 1,
            textAlign: "left",
            content: "万",
            style: {
              fontSize: 36,
            },
          },
        },
        {
          title: "服务人口",
          number: {
            number: [2001],
            toFixed: 1,
            textAlign: "left",
            content: "万",
            style: {
              fontSize: 36,
            },
          },
        },
      ],
      options: {},
    };
  },
  components: {
    // CenterChart,
  },
  mounted() {
    this.$nextTick(() => {
      this.drawManage();
    });
  },
  methods: {
    drawManage() {
      var myChart = this.$echarts.init(
        document.getElementById("temperature-line")
      );
      var option = {
        title: {
          text: "各区县用户数",
          textStyle: {
            color: "#ffffff",
            fontFamily: "electronicFont",
          },
        },
        grid: {
          left: "15%",
        },
        xAxis: {
          type: "category",
          data: [
            "定兴县",
            "阜平县",
            "竞秀区",
            "满城区",
            "徐水区",
            "莲池区",
            "清苑区",
          ],
          axisLine: {
            lineStyle: {
              color: "#ffffff",
              fontFamily: "electronicFont",
            },
          },
          axisLabel: {
            rotate: 45,
            margin: 12,
          },
        },
        yAxis: {
          type: "value",
          axisLine: {
            lineStyle: {
              color: "#ffffff",
              fontFamily: "electronicFont",
            },
          },
          splitLine: {
            show: false, //不显示网格线
          },
          axisLabel: {
            rotate: 15,
            margin: 12,
          },
        },
        series: [
          {
            data: [150, 230, 224, 218, 135, 147, 260],
            type: "line",
          },
        ],
      };
      myChart.setOption(option, true);
      window.addEventListener("resize", () => {
        myChart.resize();
      });
    },
  },
};
</script>

<style lang="scss" scoped>
#centerBottom {
  display: flex;
  height: 48vh;
  flex-direction: column;
  .bottomLeftTitle {
    flex: 1.2;
    padding: 0.15vh 0.55vw;
    text-align: left;
    font-size: 2vw;
    font-weight: bold;
    .asTitle {
      padding-left: 2vw;
      // 使用相对位置让其垂直居中
      position: relative;
      top: 50%;
      transform: translateY(-50%);
    }
  }
  .up {
    flex: 2;
    width: 95%;
    margin: 0.1vh auto;
    display: flex;
    flex-direction: column;
    .secondTitle {
      flex: 1;
      font-size: 1.2vw;
      padding: 0.1vh 2.5vw;
      font-weight: bold;
    }
    .secondItem {
      flex: 2;
      display: flex;
      flex-wrap: wrap;
      justify-content: center;
      align-items: center;
      .item {
        text-align: center;
        border-radius: 0.1vh;
        padding-top: 0.1vh;
        margin-top: 0.1vh;
        width: 33%;
        .dv-dig-flop {
          font-size: 1vw;
        }
      }
    }
  }
  .down {
    flex: 4;
    padding: 0.6vh 0.4vw;
    padding-bottom: 0;
    // display: flex;
    justify-content: space-between;
    .ranking {
      margin: 0 auto;
      padding: 0.1vh;
      width: 95%;
      .chart-con {
        height: 23vh;
        width: 100%;
      }
    }
  }
}
</style>
